<?php
namespace app\common\model;

use think\Db;
use think\Model;

/**   YSF
 *    动态组  Model
 *    Date: 2018/7/26
 * Class DynamicGroupModel
 * @package app\common\model
 */
class DynamicGroupModel extends Model
{
    // 表名
    protected $dbName = 'dynamic_group';

    // 获取列表
    public function getAll($where, $page, $pageSize, $field, $order)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->field($field)
                    ->page($page, $pageSize)
                    ->order($order)
                    ->select();
//        echo Db::name($this->dbName)->getLastSql();die();
        return $result;
    }

    // 获取数量
    public function getCount($where)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->count();
        return $result;
    }

    // 添加一条数据
    public function add($data)
    {
        $result = Db::name($this->dbName)->insertGetId($data);

        return $result;
    }

    // 修改操作
    public function edit($where, $data)
    {
        $result = Db::name($this->dbName)
                    ->where($where)
                    ->update($data);
        return $result;
    }

}